package com.yuand.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yuand.entity.SysDictData;
import com.yuand.entity.SysDictType;
import com.yuand.service.SysDictDataService;
import com.yuand.service.SysDictTypeService;
import com.yuand.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 字典数据表 前端控制器
 * </p>
 *
 * @author yuandong
 * @since 2022-02-11
 */
@RestController
@RequestMapping("/sys/dict/data")
public class SysDictDataController {

    @Autowired
    private SysDictDataService sysDictDataService;

    /**
     * 查询字典列表
     * @param dictData
     * @return
     */
    @GetMapping("/list")
    public ResponseResult list(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, SysDictData dictData) {
        PageHelper.startPage(pageNum, pageSize);
        List<SysDictData> list = this.sysDictDataService.selectDictDataList(dictData);
        PageInfo<SysDictData> pageInfo = new PageInfo<>(list);
        return new ResponseResult(0, "操作成功", pageInfo);
    }


    @GetMapping("/{dictType}")
    public ResponseResult getDictDataByType(@PathVariable String dictType){

        List<SysDictData> list = this.sysDictDataService.selectDictDataByType(dictType);
        return new ResponseResult(0, "操作成功", list);
    }




}
